<template>
  <el-dialog :visible.sync="dialogVisible" width="90%" :close-on-click-modal="false" title="订阅任务" :z-index="1004">
    <template>
      <el-form :model="formObj" label-width="120px">
        <el-form-item label="wx合集地址">
          <el-input type="textarea" rows="10" v-model="formObj.url" placeholder="请输入wx的合集地址"></el-input>
        </el-form-item>
        <el-form-item label="触发时机">
          <el-input v-model="formObj.cronexpression" placeholder="请输入触发时机"></el-input>
        </el-form-item>
        <el-form-item label="备注">
          <el-input v-model="formObj.notes"></el-input>
        </el-form-item>
      </el-form>
    </template>
    <template #footer>
      <el-button @click="dialogVisible = false">取消</el-button>
      <el-button type="primary" @click="handleSubmitNewTask">确定</el-button>
    </template>
  </el-dialog>
</template>

<script>
import { save } from '@/api/imgManage/subscribeArticles'
export default {
  name: '',
  components: {},
  props: {
    args: {}
  },
  data() {
    return {
      dialogVisible: false,
      defaultFormObj: {
        url: '',
        cronexpression: '0 0 1 * * ?',
        notes: ''
      },
      formObj: {}
    }
  },
  computed: {},
  methods: {
    async handleSubmitNewTask(){
      if(this.args.mode === 'add'){
        this.$modal.loading("正在处理，请稍候...");
        const res = await save(this.formObj)
        if(res.code == 200){
          this.$modal.msgSuccess("新增成功");
          this.$emit('callBack')
          this.dialogVisible = false
        } else {
          this.$modal.msgError("新增失败");
        }
        this.$modal.closeLoading()
      }
    },
    init(){
      this.dialogVisible = true
      if(this.args.mode === 'add'){
        this.formObj = this.defaultFormObj
      }
    }
  },
  mounted() {

  }
}
</script>


<style scoped lang="scss">

</style>
